//
//  OptionTableViewCell.m
//  图片故事
//
//  Created by 大帅逼 on 16/2/4.
//  Copyright © 2016年 helloApp. All rights reserved.
//

#import "OptionTableViewCell.h"
#import "Header.h"

#define MARGIN 10

@interface OptionTableViewCell ()

@property(nonatomic,strong) UIImageView     *optionImageView;
@property(nonatomic,strong) UILabel         *optionTitleLabel;

@end

@implementation OptionTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {

    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        // 初始化子控件
        _optionImageView = [[UIImageView alloc] init];
        
        [self.contentView addSubview:_optionImageView];
        
        _optionTitleLabel = [[UILabel alloc] init];
        
        [_optionTitleLabel setTextColor:[UIColor grayColor]];
        
        [_optionTitleLabel setFont:[UIFont systemFontOfSize:14]];
        
        [self.contentView addSubview:_optionTitleLabel];
        
        _lineView = [[UIView alloc] init];
        
        [_lineView setBackgroundColor:[UIColor grayColor]];
        
        [self.contentView addSubview:_lineView];
    }
    
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];

    // 设置子控件的位置
    [_optionImageView setFrame:CGRectMake(My_Width(MARGIN), My_Height(MARGIN), My_Height(40), My_Height(40))];
    
    [_optionTitleLabel setFrame:CGRectMake(My_Width(60), My_Height(20), SCREEN_W - My_Width(100), My_Height(20))];
    
    [_lineView setFrame:CGRectMake(MARGIN, My_Height(59.5), SCREEN_W - MARGIN, 0.5)];
}

- (void)setOption:(OptionModal *)option {

    // 设置子控件数据
    _option = option;
    
    [_optionImageView setImage:[UIImage imageNamed:option.optionImage]];
    
    [_optionTitleLabel setText:option.optionTitle];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

@end
